package com.liang.liangrpccore.service;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;

public class VertxHttpServer implements HttpService{

    public void doStart(int port) {
        // 创建示例
        Vertx vertx = Vertx.vertx();
        // 创建http服务器
        HttpServer httpServer = vertx.createHttpServer();

        // 引入http服务处理器
        httpServer.requestHandler(new HttpServiceHandler());

        // 监听指定端口
        httpServer.listen(port, result -> {
            if (result.succeeded()) {
                System.out.println("http server started on port " + port);
            } else {
                System.out.println("http server start failed");
            }
        });
    }
}
